#ifndef EVM_PROCESS_H
#define EVM_PROCESS_H

#include <stdint.h>

#include "evm_config.h"
#include "evm_error.h"
#include "evm_memory.h"
#include "evm_opcode.h"
#include "evm_stack.h"
#include "evm.h"

enum evm_process_state {
    INIT,
    STOPPED,
    RUNNING,
    SUSPENDED,

    WAITING_MESSAGE,
    WAITING_EVENT
};

typedef struct evm_process {
    uint32_t     process_id;
    uint32_t     state;
    struct evm  *vm;
    char        *process_name;

    evm_memory  *memory;

    evm_stack   *data_stack;
    evm_stack   *call_stack;
    evm_stack   *args_stack;

    evm_command *pc;
} evm_process;

evm_process* evm_process_new      ( struct evm* vm, const char *name );
evm_process* evm_process_from_file( struct evm* vm, const char *name, const char *file_name );

void         evm_process_free ( evm_process *proc );

uint32_t     evm_arg        (evm_process *proc, int32_t argNo, void *data );
uint32_t     evm_stack_data ( evm_process *proc, int32_t stackLevel, void *data );

#endif // EVM_PROCESS_H
